import { request } from "../request";

export interface UpdateQuestionParams {
    questionId?: number;
    creatorId?: number;
    content?: string;
    options?: Record<string, unknown>;
    answer?: string;
    difficulty?: string;
    createdAt?: Record<string, unknown>;
    type?: number;
}

export interface UpdateQuestionRes {
    code: number;
    message: string;
    data: string;
    timestamp: Record<string, unknown>;
}

const updateQuestionAPI = async (params: UpdateQuestionParams): Promise<UpdateQuestionRes> => {
    const token = localStorage.getItem("token");
    return request("/api/questions/update", {
        method: "put",
        headers: {
            "Content-Type": "application/json",
            "Authorization": `Bearer ${token}`,
        },
        data: params,
    });
};

export default updateQuestionAPI;
